#include "../circuit/circuit.hh"
#include "../circuit/componet.hh"

#include <optional>
#include <string>
#include <string_view>
#include <unordered_map>
#include <memory>
#include <vector>
#include <string>

namespace ycspice::preprocess {

    struct SubcktInfo {
        std::string name;
        std::vector<std::string> ports;
        std::vector<std::string> insts;
    };  

    class Factory {
    public:
        Factory() = default;
        ~Factory() noexcept = default;

    public:
        auto emplace_subckt_info(std::string name, SubcktInfo info) -> void;

    public:
        auto create_subckt(std::string_view name) -> Circuit*;
        auto create_subckt(const SubcktInfo& info) -> Circuit*;
        auto create_componet(ComponetType type, std::string value) -> Circuit*;
        auto circuit(std::string_view name) const -> std::optional<Circuit*>;

    private:
        std::unordered_map<std::string, std::unique_ptr<Circuit>> _circuits{};
        std::unordered_map<std::string, SubcktInfo> _subckt_infos{};
    };

}